const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
const pngquant = require('imagemin-pngquant');
var postcss = require('gulp-postcss')
var autoprefixer = require('autoprefixer')
var rem = require('gulp-rem');
var spriter = require('gulp-css-spriter');
var debug = require('gulp-debug');

gulp.task('img', () =>
gulp.src('_asset/*')
    .pipe(imagemin({
        //optimizationLevel: 7, //类型：Number  默认：3  取值范围：0-7（优化等级）
        progressive: true, //类型：Boolean 默认：false 无损压缩jpg图片
        use: [pngquant()]
    }))
    .pipe(gulp.dest('./asset'))
);

gulp.task('css', () =>gulp.src([
    '_css/*.css'
])
    .pipe(postcss([
        autoprefixer({
            //browsers: ["Android 4.1", "iOS 7.1", "Chrome > 31", "ff > 31", "ie >= 10"]
            browsers: ["Android 4.1", "iOS 7.1", "Chrome > 31"]
        })
    ]))
   /* .pipe(rem({
        width:1440,
        unit:'px'
    }))*/
    .pipe(gulp.dest('css'))
);

gulp.task("cssb",function(){
    return gulp.src('css/*.css')
        .pipe(spriter({
            'spriteSheet': './dist/spritesheet.png',
        }))
        .pipe(gulp.dest('./dist'));
})
